/*
 * GridUserJPanel.java
 *
 * Created on Utorok, 2007, november 6, 14:08
 */

package gui;

import java.awt.FocusTraversalPolicy;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import logic.distributions.AbstractGenerator;
import logic.distributions.ConstantGenerator;
import logic.distributions.ExponentialGenerator;
import logic.distributions.NormalGenerator;
import logic.distributions.UniformGenerator;
import logic.gridNodes.GridUser;
import javax.swing.JLabel;
import logic.gridSimInterface.SimTags;

/**
 *
 * @author  handsome
 */
public class GridUserJPanel extends ParametersPanel {
    
    GridUser User = null;  
    DistributionDialog DF;
    
    /** Creates new form GridUserJPanel */
    public GridUserJPanel(JFrame owner) {
        initComponents();

        DF = new DistributionDialog(owner);
        DF.addParametersChangeListener(new DistributionDialog.DistributionParametersListener() {

            public void parametersChanged(AbstractGenerator g) {
            showGeneratorsParam();
            }
        });
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        propertyPanel = new javax.swing.JPanel();
        NameJLbl = new javax.swing.JLabel();
        NameJTxtField = new javax.swing.JTextField();
        GeneratorsJLbl = new javax.swing.JLabel();
        OSJLbl = new javax.swing.JLabel();
        ArchitectJLbl = new javax.swing.JLabel();
        TasksCJLbl = new javax.swing.JLabel();
        GridLTypeJLbl = new javax.swing.JLabel();
        WorkflowJLbl = new javax.swing.JLabel();
        OSJTxtField = new javax.swing.JTextField();
        ArchitectureJTxtField = new javax.swing.JTextField();
        TasksJTxtField = new javax.swing.JTextField();
        GridletJCmbBox = new javax.swing.JComboBox();
        WorkflowJTxtField = new javax.swing.JTextField();
        TaskLngJLbl = new javax.swing.JLabel();
        FilesSizeJLbl = new javax.swing.JLabel();
        OutputSizeJLbl = new javax.swing.JLabel();
        StartTimeJLbl = new javax.swing.JLabel();
        TaskLngJCmbBox = new javax.swing.JComboBox();
        TaskLngSPJbtn = new javax.swing.JButton();
        FileSizeJCmbBox = new javax.swing.JComboBox();
        TaskLngParamJLbl = new javax.swing.JLabel();
        FileSizeParamJLbl = new javax.swing.JLabel();
        StartTimeJCmbBox = new javax.swing.JComboBox();
        FileSizeSPJBtn = new javax.swing.JButton();
        StartTimeSPJBtn = new javax.swing.JButton();
        StartTimeParamJLbl = new javax.swing.JLabel();
        OutputSizeJCmbBox = new javax.swing.JComboBox();
        OutputSzieSPJBtn = new javax.swing.JButton();
        OutputSizeParamJLbl = new javax.swing.JLabel();

        setMinimumSize(new java.awt.Dimension(310, 650));
        setPreferredSize(new java.awt.Dimension(310, 650));
        NameJLbl.setText("Name :");

        NameJTxtField.setFocusTraversalPolicy(getFocusTraversalPolicy());
        NameJTxtField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NameJTxtFieldActionPerformed(evt);
            }
        });
        NameJTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                NameJTxtFieldFocusLost(evt);
            }
        });

        GeneratorsJLbl.setText("<html>\ng<br>\ne<br>\nn<br>\ne<br>\nr<br>\na<br>\nt<br>\no<br>\nr<br>\ns\n</html>");

        OSJLbl.setText("Operating System :");

        ArchitectJLbl.setText("Architecture :");

        TasksCJLbl.setText("Tasks-count :");

        GridLTypeJLbl.setText("Gridlet type :");

        WorkflowJLbl.setText("Workflow :");

        OSJTxtField.setFocusTraversalPolicy(getFocusTraversalPolicy());
        OSJTxtField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OSJTxtFieldActionPerformed(evt);
            }
        });
        OSJTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                OSJTxtFieldFocusLost(evt);
            }
        });

        ArchitectureJTxtField.setFocusTraversalPolicy(getFocusTraversalPolicy());
        ArchitectureJTxtField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ArchitectureJTxtFieldActionPerformed(evt);
            }
        });
        ArchitectureJTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                ArchitectureJTxtFieldFocusLost(evt);
            }
        });

        TasksJTxtField.setFocusTraversalPolicy(getFocusTraversalPolicy());
        TasksJTxtField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TasksJTxtFieldActionPerformed(evt);
            }
        });
        TasksJTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                TasksJTxtFieldFocusLost(evt);
            }
        });

        GridletJCmbBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Simple ", "Complex", "Workflow" }));
        GridletJCmbBox.setFocusTraversalPolicy(getFocusTraversalPolicy());
        GridletJCmbBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GridletJCmbBoxActionPerformed(evt);
            }
        });
        GridletJCmbBox.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                GridletJCmbBoxFocusLost(evt);
            }
        });

        WorkflowJTxtField.setFocusTraversalPolicy(getFocusTraversalPolicy());
        WorkflowJTxtField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                WorkflowJTxtFieldActionPerformed(evt);
            }
        });
        WorkflowJTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                WorkflowJTxtFieldFocusLost(evt);
            }
        });

        TaskLngJLbl.setText("Task length :");

        FilesSizeJLbl.setText("File size :");

        OutputSizeJLbl.setText("Output size :");

        StartTimeJLbl.setText("Start-time :");

        TaskLngJCmbBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Constant", "Uniform", "Normal", "Exponential" }));
        TaskLngJCmbBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TaskLngJCmbBoxActionPerformed(evt);
            }
        });

        TaskLngSPJbtn.setText("Set parameters");
        TaskLngSPJbtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TaskLngSPJbtnActionPerformed(evt);
            }
        });

        FileSizeJCmbBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        FileSizeJCmbBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FileSizeJCmbBoxActionPerformed(evt);
            }
        });

        TaskLngParamJLbl.setText("<html> param : values <br> param : values </html>");
        TaskLngParamJLbl.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        FileSizeParamJLbl.setText("<html> param : values <br> param : values  </html>");
        FileSizeParamJLbl.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        StartTimeJCmbBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        StartTimeJCmbBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StartTimeJCmbBoxActionPerformed(evt);
            }
        });

        FileSizeSPJBtn.setText("Set parameters");
        FileSizeSPJBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FileSizeSPJBtnActionPerformed(evt);
            }
        });

        StartTimeSPJBtn.setText("Set parameters");
        StartTimeSPJBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StartTimeSPJBtnActionPerformed(evt);
            }
        });

        StartTimeParamJLbl.setText("<html> param : values <br> param : values  </html>");
        StartTimeParamJLbl.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        OutputSizeJCmbBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        OutputSizeJCmbBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OutputSizeJCmbBoxActionPerformed(evt);
            }
        });

        OutputSzieSPJBtn.setText("Set parameters");
        OutputSzieSPJBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OutputSzieSPJBtnActionPerformed(evt);
            }
        });

        OutputSizeParamJLbl.setText("<html> param : values <br> param : values </html>");
        OutputSizeParamJLbl.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(OutputSizeJLbl)
                    .addComponent(OSJLbl)
                    .addComponent(NameJLbl)
                    .addComponent(TasksCJLbl)
                    .addComponent(ArchitectJLbl)
                    .addComponent(WorkflowJLbl)
                    .addComponent(GridLTypeJLbl)
                    .addComponent(StartTimeJLbl)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(GeneratorsJLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TaskLngJLbl, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(FilesSizeJLbl, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(StartTimeParamJLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(StartTimeSPJBtn)
                    .addComponent(OutputSizeParamJLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(OutputSzieSPJBtn)
                    .addComponent(FileSizeParamJLbl)
                    .addComponent(FileSizeSPJBtn)
                    .addComponent(TaskLngParamJLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TaskLngSPJbtn)
                    .addComponent(OSJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(NameJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TasksJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GridletJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(WorkflowJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(StartTimeJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ArchitectureJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TaskLngJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(FileSizeJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(OutputSizeJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(4, 4, 4))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NameJLbl)
                    .addComponent(NameJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(OSJLbl)
                    .addComponent(OSJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ArchitectJLbl)
                    .addComponent(ArchitectureJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TasksCJLbl)
                    .addComponent(TasksJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(GridLTypeJLbl)
                            .addComponent(GridletJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(WorkflowJLbl)
                            .addComponent(WorkflowJTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(15, 15, 15)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(StartTimeJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(StartTimeJLbl))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(StartTimeSPJBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(StartTimeParamJLbl)
                        .addGap(21, 21, 21)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TaskLngJLbl)
                            .addComponent(TaskLngJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TaskLngSPJbtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TaskLngParamJLbl)
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(FilesSizeJLbl)
                            .addComponent(FileSizeJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(FileSizeSPJBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(FileSizeParamJLbl)
                        .addGap(15, 15, 15)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(OutputSizeJLbl)
                            .addComponent(OutputSizeJCmbBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(OutputSzieSPJBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(OutputSizeParamJLbl))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(169, 169, 169)
                        .addComponent(GeneratorsJLbl)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void OutputSzieSPJBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OutputSzieSPJBtnActionPerformed
        DF.setDistribution(User.getOutputSize());
        DF.setVisible(true);
    }//GEN-LAST:event_OutputSzieSPJBtnActionPerformed

    private void StartTimeSPJBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartTimeSPJBtnActionPerformed
        DF.setDistribution(User.getStartTime());
        DF.setVisible(true);               
    }//GEN-LAST:event_StartTimeSPJBtnActionPerformed

    private void FileSizeSPJBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FileSizeSPJBtnActionPerformed
        DF.setDistribution(User.getFileSize());
        DF.setVisible(true);
    }//GEN-LAST:event_FileSizeSPJBtnActionPerformed

    private void OutputSizeJCmbBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OutputSizeJCmbBoxActionPerformed
        if (! Initialization){
            User.setOutputSize(ComboBoxGeneratorType(OutputSizeJCmbBox.getSelectedIndex()));
            showGeneratorsParam();
        }
    }//GEN-LAST:event_OutputSizeJCmbBoxActionPerformed

    private void StartTimeJCmbBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartTimeJCmbBoxActionPerformed
        if (! Initialization){
            User.setStartTime(ComboBoxGeneratorType(StartTimeJCmbBox.getSelectedIndex()));
            showGeneratorsParam();
        }
    }//GEN-LAST:event_StartTimeJCmbBoxActionPerformed

    private void FileSizeJCmbBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FileSizeJCmbBoxActionPerformed
        if (! Initialization){
            User.setFileSize(ComboBoxGeneratorType(FileSizeJCmbBox.getSelectedIndex()));
            showGeneratorsParam();
        }         
    }//GEN-LAST:event_FileSizeJCmbBoxActionPerformed
        
    
    private void TaskLngSPJbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TaskLngSPJbtnActionPerformed
        DF.setDistribution(User.getTaskLength());
        DF.setVisible(true);
    }//GEN-LAST:event_TaskLngSPJbtnActionPerformed
                    
    
    
    private void TaskLngJCmbBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TaskLngJCmbBoxActionPerformed
        if (! Initialization) {
            User.setTaskLength(ComboBoxGeneratorType(TaskLngJCmbBox.getSelectedIndex()));
            showGeneratorsParam();
        }        
    }//GEN-LAST:event_TaskLngJCmbBoxActionPerformed
    
    /**
     * Vracia vsetky parametre genratora ako string 
     * @param AbstrGen je generator, ktoreho paramtre sa nacitavaju do stringu
     */    
    private String GetParamValues(AbstractGenerator AbstrGen){ //nacita do stringu parametre generatora
       String result = "<html>";
       for (int i = 0; i < AbstrGen.getParamsCount(); i++) {
           result = result + AbstrGen.getParameterName(i) + ": " 
                   + AbstrGen.getParameter(i).toString();
           result = result + " <br>";           
       }
       result = result + " </html>";       
       return result;
    }
    
    /**
     * Zobrazuje vsetky parametre generatorov na paneli
     */
    private void showGeneratorsParam(){ // nastavi hodnoty na paneli         
        TaskLngParamJLbl.setText(GetParamValues(User.getTaskLength()));
        FileSizeParamJLbl.setText(GetParamValues(User.getFileSize()));
        StartTimeParamJLbl.setText(GetParamValues(User.getStartTime()));
        OutputSizeParamJLbl.setText(GetParamValues(User.getOutputSize()));
    }
    
    /**
     * Nastavi pre vsetky generatory hodnoty combo-boxov
     */
    private void ComboBoxesItemsSet(){ // nastavi vsetkym comboboxom rovnake itemy ako ma prvy - tasksLengthCmbBox
        FileSizeJCmbBox.removeAllItems();
        StartTimeJCmbBox.removeAllItems();
        OutputSizeJCmbBox.removeAllItems();
        for(int i = 0; i < TaskLngJCmbBox.getItemCount(); i++){            
            FileSizeJCmbBox.addItem(TaskLngJCmbBox.getItemAt(i));            
            StartTimeJCmbBox.addItem(TaskLngJCmbBox.getItemAt(i));
            OutputSizeJCmbBox.addItem(TaskLngJCmbBox.getItemAt(i));                        
        }
    }
   
    /**
     * Vracia generator podla typu vyberu z combo-boxu
     * @param Number je polozka v combo-boxe
     */
    private AbstractGenerator ComboBoxGeneratorType(int Number){
        switch (Number) {
            case 0: 
                    return new logic.distributions.ConstantGenerator();
            case 1:
                    return new logic.distributions.UniformGenerator();   
            case 2:
                    return new logic.distributions.NormalGenerator();
            case 3:
                    return new logic.distributions.ExponentialGenerator();
            default:
                    return null;                
        }    
    }
    
   /**
    * Vracia poziciu v combo-boxe zodpovedajucu typu generatora
    * @param AbstrGen je generator pre ktory sa vracia dana pozicia   
    */
   private int GetGeneratorIndex(AbstractGenerator AbstrGen){
       if (AbstrGen instanceof ConstantGenerator ){
           return 0;
       } else if (AbstrGen instanceof UniformGenerator){
           return 1;
       } else if (AbstrGen instanceof NormalGenerator) {
           return 2;
       } else if (AbstrGen instanceof ExponentialGenerator) {
           return 3;
       }
       return -1;
   }
   
    /**
     * Umoznuje editovat workflow v pripade, ze bol Gridlet type zvoleny ako workflow
     */
    private void WorkflowTxtLabelSetEnabled(){        
        if (User.getGridletType() == SimTags.GRIDLET_TYPE_WORKFLOW) {
            WorkflowJTxtField.setEnabled(true);
        } else WorkflowJTxtField.setEnabled(false);        
    }
    
    /**
     * Umoznuje nastavovat parametere pre Start-time generator v pripade, za gridlet type je rozny od Simple  
     */
    private void StartTimeGenSetEnabled(){
        if (User.getGridletType() == SimTags.GRIDLET_TYPE_SIMPLE) {
            StartTimeJCmbBox.setEnabled(false);
            StartTimeSPJBtn.setEnabled(false);
            StartTimeParamJLbl.setEnabled(false);            
        }   else {
            StartTimeJCmbBox.setEnabled(true);
            StartTimeSPJBtn.setEnabled(true);
            StartTimeParamJLbl.setEnabled(true);           
        }
    }

    private void WorkflowJTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WorkflowJTxtFieldActionPerformed
        workflowSet();
    }//GEN-LAST:event_WorkflowJTxtFieldActionPerformed

    private void GridletJCmbBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GridletJCmbBoxActionPerformed
        gridletTypeSet();
        WorkflowTxtLabelSetEnabled();  
        StartTimeGenSetEnabled();
    }//GEN-LAST:event_GridletJCmbBoxActionPerformed

    private void TasksJTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TasksJTxtFieldActionPerformed
        tasksCountSet();
    }//GEN-LAST:event_TasksJTxtFieldActionPerformed

    private void ArchitectureJTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ArchitectureJTxtFieldActionPerformed
        architectureSet();
    }//GEN-LAST:event_ArchitectureJTxtFieldActionPerformed

    private void OSJTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OSJTxtFieldActionPerformed
        OSSet();
    }//GEN-LAST:event_OSJTxtFieldActionPerformed

    private void NameJTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NameJTxtFieldActionPerformed
        nameSet();
    }//GEN-LAST:event_NameJTxtFieldActionPerformed

    /**
     * Nastavuje pre Usera parameter Gridlet type 
     */
    private void gridletTypeSet() {
        User.setGridletType(GridletJCmbBox.getSelectedIndex()+1);        
    }
    
    private void GridletJCmbBoxFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_GridletJCmbBoxFocusLost
        gridletTypeSet();
        WorkflowTxtLabelSetEnabled(); 
        StartTimeGenSetEnabled();
    }//GEN-LAST:event_GridletJCmbBoxFocusLost

    /**
     * Nastavuje pre Usera parameter Workflow
     */
    private void workflowSet() {       
        if (User.getGridletType() == SimTags.GRIDLET_TYPE_WORKFLOW) {
            int Workflow;            
            try {
                Workflow = Integer.parseInt(WorkflowJTxtField.getText());
                if ((Workflow >0) && (Workflow < User.getTasksCount())){
                    User.setWorkflow(Integer.valueOf(WorkflowJTxtField.getText()).intValue());        
                } else {
                    User.setWorkflow(User.getTasksCount()-1);
                    WorkflowJTxtField.setText(((Integer)User.getWorkflow()).toString());
                    GangstersGrid.showErrorMessage("Value of workflow must be lower than value of tasks count.");
                }                    
            } catch (NumberFormatException ex3) {
                WorkflowJTxtField.setText(((Integer)User.getWorkflow()).toString());
                GangstersGrid.showErrorMessage("Value of workflow must be a number.");                    
            }
        }
    }
    

    private void WorkflowJTxtFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_WorkflowJTxtFieldFocusLost
        workflowSet();
    }//GEN-LAST:event_WorkflowJTxtFieldFocusLost

    /**
     * Nastavuje pre Usera parameter Tasks-count (pocet uloh) 
     */
    private void tasksCountSet() {
        int TasksCount;
        try {
            TasksCount = Integer.parseInt(TasksJTxtField.getText());
            if (TasksCount > 0)
                User.setTasksCount(TasksCount);
            else {
                TasksJTxtField.setText(String.valueOf(User.getTasksCount()));
                GangstersGrid.showErrorMessage("Value of task-count must be greater than zero.");                    
            }
        } catch (NumberFormatException ex2) {
            TasksJTxtField.setText(String.valueOf(User.getTasksCount()));
            GangstersGrid.showErrorMessage("Value of task-count must be a number.");                    
        }                         
    }
    
    private void TasksJTxtFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_TasksJTxtFieldFocusLost
        tasksCountSet();
    }//GEN-LAST:event_TasksJTxtFieldFocusLost
    
    /**
     * Nastavuje pre Usera parameter Architecture (Architektura)
     */
    private void architectureSet() {
        if (!ArchitectureJTxtField.getText().isEmpty()) {
            User.setArchitecture(ArchitectureJTxtField.getText());
        } else {
            ArchitectureJTxtField.setText(User.getArchitecture());
            GangstersGrid.showErrorMessage("Architecture must be defined.");
        }                    
    }
    
    private void ArchitectureJTxtFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ArchitectureJTxtFieldFocusLost
        architectureSet();
    }//GEN-LAST:event_ArchitectureJTxtFieldFocusLost

    /**
     * Nastavuje pre Usera parameter Operating System (Operacny System)
     */
    private void OSSet() {
        if (!OSJTxtField.getText().isEmpty()) {
            User.setOs(OSJTxtField.getText());
        } else {
            OSJTxtField.setText(User.getOs());
            GangstersGrid.showErrorMessage("Operation system must be defined.");
        }                    
    }
    
    private void OSJTxtFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_OSJTxtFieldFocusLost
        OSSet();
    }//GEN-LAST:event_OSJTxtFieldFocusLost

    /**
     * Nastavuje pre Usera parameter Name (Meno)
     */
    private void nameSet() {
        try {
            User.setName(NameJTxtField.getText());
        } catch (Exception ex) {
            NameJTxtField.setText(User.getName());
            GangstersGrid.showErrorMessage(ex.getMessage());
        }
    }
    
    private void NameJTxtFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_NameJTxtFieldFocusLost
        nameSet();
    }//GEN-LAST:event_NameJTxtFieldFocusLost
    
    /**
     * Nastavuje pre Usera vsetky jeho potrebne parametre
     */
    public void FillUpUserDetails(){ // nastavi hodnoty atributov User-ovi
        nameSet();
        OSSet();
        architectureSet();
        tasksCountSet();
        gridletTypeSet();
        workflowSet();
    }
        
        
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ArchitectJLbl;
    private javax.swing.JTextField ArchitectureJTxtField;
    private javax.swing.JComboBox FileSizeJCmbBox;
    private javax.swing.JLabel FileSizeParamJLbl;
    private javax.swing.JButton FileSizeSPJBtn;
    private javax.swing.JLabel FilesSizeJLbl;
    private javax.swing.JLabel GeneratorsJLbl;
    private javax.swing.JLabel GridLTypeJLbl;
    private javax.swing.JComboBox GridletJCmbBox;
    private javax.swing.JLabel NameJLbl;
    private javax.swing.JTextField NameJTxtField;
    private javax.swing.JLabel OSJLbl;
    private javax.swing.JTextField OSJTxtField;
    private javax.swing.JComboBox OutputSizeJCmbBox;
    private javax.swing.JLabel OutputSizeJLbl;
    private javax.swing.JLabel OutputSizeParamJLbl;
    private javax.swing.JButton OutputSzieSPJBtn;
    private javax.swing.JComboBox StartTimeJCmbBox;
    private javax.swing.JLabel StartTimeJLbl;
    private javax.swing.JLabel StartTimeParamJLbl;
    private javax.swing.JButton StartTimeSPJBtn;
    private javax.swing.JComboBox TaskLngJCmbBox;
    private javax.swing.JLabel TaskLngJLbl;
    private javax.swing.JLabel TaskLngParamJLbl;
    private javax.swing.JButton TaskLngSPJbtn;
    private javax.swing.JLabel TasksCJLbl;
    private javax.swing.JTextField TasksJTxtField;
    private javax.swing.JLabel WorkflowJLbl;
    private javax.swing.JTextField WorkflowJTxtField;
    private javax.swing.JPanel propertyPanel;
    // End of variables declaration//GEN-END:variables

    private boolean Initialization;
    
    public void setObject(Object o) {            
        Initialization = true;
        User = ((GridUser)o);
        ComboBoxesItemsSet();
        NameJTxtField.setText(User.getName());
        OSJTxtField.setText(User.getOs());
        ArchitectureJTxtField.setText(User.getArchitecture());
        TasksJTxtField.setText(String.valueOf(User.getTasksCount()));         
        GridletJCmbBox.setSelectedIndex(User.getGridletType()-1);        
        WorkflowJTxtField.setText(((Integer)User.getWorkflow()).toString());        
        TaskLngJCmbBox.setSelectedIndex(GetGeneratorIndex(User.getTaskLength()));
        StartTimeJCmbBox.setSelectedIndex(GetGeneratorIndex(User.getStartTime()));
        FileSizeJCmbBox.setSelectedIndex(GetGeneratorIndex(User.getFileSize()));
        OutputSizeJCmbBox.setSelectedIndex(GetGeneratorIndex(User.getOutputSize()));
        showGeneratorsParam();
        Initialization = false;
    }

    public void saveObjectValues() {
        if (User != null) {            
        FillUpUserDetails();
        }
    }

   
    
}
